package com.dong.es.entity;

import co.elastic.clients.elasticsearch._types.aggregations.Aggregate;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * @description: ES 返回数据对象
 * @author: 陈瑞东
 * @create: 2022-05-19 10:03
 */
public class EsResult<T> implements Serializable {

    private static final long serialVersionUID = -7145321632970996898L;

    // 查询数据
    private T data;

    // 查到的数据总量
    private Long total;

    // 聚合
    private Map<String, Aggregate> aggregations;

    // 分页数据
    private List<String> searchAfter;


    public EsResult(T data, Long total) {
        this.data = data;
        this.total = total;
    }

    public EsResult(T data, Long total, Map<String, Aggregate> aggregations) {
        this.data = data;
        this.total = total;
        this.aggregations = aggregations;
    }

    public EsResult(T data, Long total, Map<String, Aggregate> aggregations, List<String> searchAfter) {
        this.data = data;
        this.total = total;
        this.aggregations = aggregations;
        this.searchAfter = searchAfter;
    }

    public T getData() {
        return data;
    }


    public List<String> getSearchAfter() {
        return searchAfter;
    }

    public void setSearchAfter(List<String> searchAfter) {
        this.searchAfter = searchAfter;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Long getTotal() {
        return total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public Map<String, Aggregate> getAggregations() {
        return aggregations;
    }

    public void setAggregations(Map<String, Aggregate> aggregations) {
        this.aggregations = aggregations;
    }
}
